package interview;

import java.util.ArrayList;
import java.util.List;

public class interview_08_04 {
    public List<List<Integer>> subsets(int[] nums) {
        List<List<Integer>> result=new ArrayList<>();
        List<Integer> path=new ArrayList<>();
        search(result,path,nums,0);
        return result;
    }
    public void search(List<List<Integer>> result,List<Integer> path,int[] nums,int index){
        if(index==nums.length) {
            result.add(new ArrayList<>(path));
            return;
        }

        path.add(nums[index]);
        search(result, path, nums, index+1);
        path.remove(path.size()-1);
        search(result, path, nums, index+1);
    }
}
